<?php
ob_start();
header('Content-Type: text/html;charset=utf-8');
require '../../vendor/autoload.php';
use sql\SqlExec;
use utils\ConfigReader;
use utils\WebBase;
use biz\PageFileMgr;
use utils\PathTool;
use Eelly\FastDFS\Client;
use store\MinioAuthorization;
use store\MinioConfig;
use Aws\S3\S3Client;
use Aws\Exception\AwsException;
use Aws\S3\MultipartUploader;
use store\MinioTool;
use utils\MimeMapping;

/*
	此文件只负责将数据表中文件上传进度更新为100%
		向数据库添加新记录在 ajax_create_fid.php 文件中处理
	如果服务器不存在此文件，则添加一条记录，百分比为100%
	如果服务器已存在相同文件，则将文件上传百分比更新为100%
*/
//$txt = "MyEclipse8.5\\u6c49\\u5316.doc";
$ret = MinioTool::putObject("tools/test.txt","123456");
var_dump($ret);

//$ret = MinioTool::putObject("tools/test.txt","123456");
//var_dump($ret);
//var_dump( MimeMapping::getType("test.txt") );

//$result = $s3Client->listBuckets();
//$names = $result->search('Buckets[].Name');
//var_dump($names);

// $ret = $client->createMultipartUpload(["Bucket"=>"test",
// "Key"=>"tools/你好.txt"]);
// var_dump($ret);

// //上传分块
// $part = $client->uploadPart(["Bucket"=>"test",
// "Body"=>"aaa",
// "Key"=>$ret["Key"],
// "PartNumber"=>1,"UploadId"=>$ret["UploadId"]]);
// var_dump($part);

// //完成分块上传
// $cmp = $client->completeMultipartUpload(["Bucket"=>"test",
// "Key"=>$ret["Key"],
// "UploadId"=>$ret["UploadId"],
// "MultipartUpload"=>["Parts"=>[
// 	["ETag"=>$part["ETag"],"PartNumber"=>1]
// ]]]);
// var_dump($cmp);
//var_dump(hash("sha256","123456"));



		// //XmlDocument doc = new XmlDocument();
		// $root = new SimpleXMLElement("<CompleteMultipartUpload/>");
		// //$root = $doc->addChild("CompleteMultipartUpload");
		// //foreach ($blocks as $b)
		// {
		// 	$part = $root->addChild("Part");
		// 	$part->addChild("ETag","aaaaaaaa");
		// 	$part->addChild("PartNumber","1");
		// }
		// var_dump($root->asXml());
//$client = new Client(ConfigReader::fastDFSConfig());
//var_dump($client->query("group1/M00/00/05/wKgAb2KCFDCEMfHvAAAAAAAAAAA636.txt"));


//date_default_timezone_set('UTC');
//2022-06-15T06:43:44+00:00Z
$timeIso= date("c");
$pos = strpos($timeIso,"+");
$timeIso = substr($timeIso,0,$pos)."Z";
var_dump($timeIso);

$timeIso = str_replace("-","",$timeIso);
$timeIso = str_replace(" ","",$timeIso);
$timeIso = str_replace(":","",$timeIso);
$timeIso = str_replace("+","",$timeIso);
var_dump($timeIso);

$pos = strpos($timeIso, "T");
$timeCur = substr($timeIso,0,$pos);
var_dump($timeCur);

echo "test";
//header('Content-Length: ' . ob_get_length());
?>
